#include "route.h"

void menu()
{
    printf("\n*****************************************\n");
    printf("*****   1. AddVex     2. AddArc     *****\n");
    printf("*****   3. DelVex     4. DelArc     *****\n");
    printf("*****   5. SearchVex  6. SearchArc  *****\n");
    printf("*****   7. ModifyVex  8. ModifyArc  *****\n");
    printf("*****   9. ShowVex    10.ShowArc    *****\n");
    printf("*****   11.ShowMap    12.ShowMatrix *****\n");
    printf("*****   13.ClearMap   14.SHowPath   *****\n");
    printf("*****   15.ClearArc   16.LayCircuit *****\n");
    printf("*****       17.PASSALLVexPath       *****\n");
    printf("*****       18.PASSALLVexLoop       *****\n");
    printf("*****            0.exit             *****\n");
    printf("*****************************************\n");
}

int main()
{
    int input = 0;

    // ������ͼ
    Map map;

    // ��ʼ����ͼ
    Sleep(1000);
    InitMap(filename, &map);
   
    Sleep(1000);

    do
    {
        string str;
        Sleep(10);
        menu();
        printf("��ѡ��>:");
        scanf("%d", &input);
        switch (input)
        {
        case ADDVex:
            cout << endl
                << "==============  ���ӵص�  ===============" << endl
                << endl;
            AddVexMap(&map);
            break;
        case ADDArc:
            cout << endl
                << "==============  ���ӵ�·  ===============" << endl
                << endl;
            AddArcMap(&map);
            break;
        case DELVex:
            cout << endl
                << "==============  ɾ���ص�  ===============" << endl
                << endl;
            DelVexMap(&map);
            break;
        case DELArc:
            cout << endl
                << "==============  ɾ����·  ===============" << endl
                << endl;
            DelArcMap(&map);
            break;
        case SEARCHVex:
            cout << endl
                << "==============  ���ҵص�  ===============" << endl
                << endl;
            SearchVexMap(&map);
            break;
        case SEARCHArc:
            cout << endl
                << "==============  ���ҵ�·  ===============" << endl
                << endl;
            SearchArcMap(&map);
            break;
        case MODIFYVex:
            cout << endl
                << "==============  �޸ĵص�  ===============" << endl
                << endl;
            ModifyVexMap(&map);
            break;
        case MODIFYArc:
            cout << endl
                << "==============  �޸ĵ�·  ===============" << endl
                << endl;
            //ModifyArcMap(&map);
            cout << "= ��·��Ϣ�ɵص��Զ����������޸�Ȩ�ޣ� =" << endl;
            break;
        case SHOWVex:
            cout << endl
                << "==============  ��ʾ�ص�  ===============" << endl
                << endl;
            ShowVexMap(&map);
            break;
        case SHOWArc:
            cout << endl
                << "==============  ��ʾ��·  ===============" << endl
                << endl;
            ShowArcMap(&map);
            break;
        case SHOWMap:
            cout << endl
                << "==============  ��ʾ��ͼ  ===============" << endl
                << endl;
            ShowMap(&map);
            break;
        case SHOWMatrix:
            cout << endl
                << "==============  ��ʾ����  ===============" << endl
                << endl;
            ShowMatrix(&map);
            break;
        case CLEARMap:
            cout << "��ȷ����յ�ͼ��?ȷ��������yes,����������no>: " << endl;

            cin >> str;
            if (str == "yes")
            {
                cout << endl
                    << "==========  ���ڸ�ʽ����ͼ...  ===========" << endl
                    << endl;
                // Sleep(10);
                ClearMap(&map);
                cout << endl
                    << "==========  ��ͼ�ѱ���ʽ��!    ===========" << endl
                    << endl;
            }
            else if (str == "no")
            {
                break;
            }
            else
            {
                cout << "�������!" << endl;
                break;
            }
        case SHOWPath:
            cout << endl
                << "============  ����һ���ص�A  ============" << endl
                << "==  ��ʾA���������еص����̼�·��  ==" << endl
                << "=============  [�������]  ==============" << endl
                << endl;
            Sleep(10);
            ShowShortest_Path(&map);
            break;

        case CLEARArc:
            cout << "��ȷ����յ�·��?ȷ��������yes,����������no>: " << endl;
            cin >> str;
            if (str == "yes")
            {
                cout << endl
                    << "==========    ����������е�·...  ===========" << endl
                    << endl;
                Sleep(10);
                ClearArc(&map);
                printf("\n@@@@@@@@@@@   ������е�·�ɹ�!  @@@@@@@@@@@\n");
                break;
            }
            else if (str == "no")
            {
                break;
            }
            else
            {
                cout << "�������!" << endl;
                break;
            }
        case LAYCIRCUIT:
            cout << endl
                << "==========    �������ɵ�·�滮...  ===========" << endl
                << "==========   [Prim generate MST]  ===========" << endl
                << endl;
            // Sleep(10);
            Lay_Circuit(&map);
            cout << "==========    ��·��������ʾ���!  ===========" << endl;
            break;
        case PASSALLVexPath:
            cout << endl
                << "==========    ��������ָ��·��...  ===========" << endl
                << "=  [ĳ�س����������еص�(���ظ�����)�������]  =" << endl
                << endl;
            PassAllVex_Path(&map);
            cout << "==========    ָ��·�����������!  ===========" << endl;
            break;
        case PASSALLVexLoop:
            cout << endl
                << "==========    ��������ָ��·��...  ===========" << endl
                << "[ĳ�س����������еص�(���ظ�����)�ص�ԭ��������]" << endl
                << endl;
            PassAllVex_Loop(&map);
            cout << "==========    ָ��·�����������!  ===========" << endl;
            break;
            break;
        case EXIT:
            cout << endl
                << "==========    ���ڱ����ļ�...  ===========" << endl
                << endl;
            // Sleep(10);
            SaveMap(filename, &map);
            printf("\n@@@@@@@@@@@   �����ļ��ɹ�!  @@@@@@@@@@@\n");

            ClearMap(&map);
            printf("\n#############  �˳���ͼ    #############\n");

            break;
        default:
            printf("\nѡ�����\n");
            break;
        }
    } while (input);

    return 0;
}